const fs = require("fs");
const path = require("path");

var fileFrom = path.join(__dirname,"/1.txt");
var fileTo = path.join(__dirname,"/8.txt");

var readStream = fs.createReadStream(fileFrom);
var writeStream = fs.createWriteStream(fileTo);

readStream.pipe(writeStream);

writeStream.on("close",()=>{
    var fileObj = fs.statSync(fileFrom);
    //赋予文件操作权限
    fs.chmodSync(fileTo,fileObj.mode);
})